<template>
<div class="odiv">
      <el-form :model="infrom" label-width="100px">
  <el-form-item label="用户名">
    <el-input type="text" v-model="infrom.user" ></el-input>
  </el-form-item>
  <el-form-item label="确认密码">
    <el-input type="password" v-model="infrom.pass"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button @click="login">登录</el-button>
  </el-form-item>
</el-form>
</div>
</template>

<script>
export default {
    data(){
        return{
            infrom:{
                user:"",
                pass:"",

            }
        }
    },
    methods:{
        login(){
            this.$axios.post("http://ceshi5.dishait.cn/admin/login",{
                username:this.infrom.user,
                password:this.infrom.pass
            }).then((res)=>{
                console.log(res);
                if(res.data.msg=="ok"){
                    localStorage.setItem("token",res.data.data.token)
                    alert("登录成功")
                    this.$router.push("/Home")
                }else{
                    alert("登录失败")
                }
            })
        }
    }
}
</script>

<style>
       .odiv{
           width: 600px;
           height: 600px;
           margin: 0 auto;
           margin-top: 150px;
       }
</style>